<template>
  <div class="admin-header">
    <div class="admin-header-name">
      欢迎：{{ $store.state.adminname }} 管理员
      <el-button @click="logout">退出</el-button>
    </div>

    <div class="admin-header-time" v-if="dateNow" v-text="dateNow"></div>
  </div>
</template>

<script>
import moment from "moment";
export default {
  data() {
    return {
      dateNow: null,
    };
  },
  mounted() {
    setInterval(() => {
      this.dateNow = moment().format("YYYY年MM月DD日 kk:mm:ss");
    }, 1000);
  },
  methods: {
    logout() {
      this.$store.commit("logout");
      this.$router.push("/admin/login");
    },
  },
};
</script>

<style lang="scss" scoped>
.admin-header-time {
  width: 200px;
  float: right;
}
.admin-header-name {
  float: right;
  padding-right: 40px;
}
</style>
